package org.jeecg.modules.demo.commoditymanagement.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.demo.commoditymanagement.entity.CommodityInfo;
import org.jeecg.modules.demo.commoditymanagement.entity.CommodityManagement;
import org.jeecg.modules.demo.commoditymanagement.mapper.CommodityManagementMapper;
import org.jeecg.modules.demo.commoditymanagement.service.ICommodityManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description: 商品管理
 * @Author: jeecg-boot
 * @Date: 2021-12-30
 * @Version: V1.0
 */
@Service
public class CommodityManagementServiceImpl extends ServiceImpl<CommodityManagementMapper, CommodityManagement> implements ICommodityManagementService {
    @Autowired
    private CommodityManagementMapper commodityManagementMapper;

    @Override
    public void updateStatus(String status, String id) {
        commodityManagementMapper.updateStatus(status, id);
        commodityManagementMapper.updateInventoryStatus(status, id);
    }

    // 根据分组id查询
    @Override
    public List<CommodityInfo> getListByGroupId(Integer pageNo, Integer pageSize, String storeId, String groupId) {
        return commodityManagementMapper.getListByGroupId(pageNo, pageSize, storeId, groupId);
    }

    //查询出售中的商品数量
    public String getOnSaleCommodityQty(String storeId) {
        return commodityManagementMapper.getOnSaleCommodityQty(storeId);
    }

    @Override
    public void updateGroupName(String groupName, String groupId) {
        commodityManagementMapper.updateGroupName(groupName, groupId);
    }

    @Override
    public List<CommodityInfo> listEx(String storeId, String name) {
        return commodityManagementMapper.listEx(storeId, name);
    }

    @Override
    public List<Map<String, Object>> search(Map<String, Object> map) {
        return commodityManagementMapper.search(map);
    }
}
